<template>
  <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="用户编号：">
        <el-input v-model="ruleForm.id" disabled class="selWidth"></el-input>
      </el-form-item>
      <el-form-item label="用户备注：">
        <el-input v-model="ruleForm.mark" type="textarea" class="selWidth"></el-input>
      </el-form-item>
      <el-form-item label="状态">
        <el-radio-group v-model="ruleForm.status">
          <el-radio :label="true">开启</el-radio>
          <el-radio :label="false">关闭</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')" v-hasPermi="['admin:user:info']">提交</el-button>
        <el-button @click="resetForm('ruleForm')">取消</el-button>
      </el-form-item>
    </el-form>
</template>

<script>
  import { groupListApi, levelListApi, tagListApi, userInfoApi, userUpdateApi } from '@/api/user'
  import {Debounce} from '@/utils/validate'
  const defaultObj = {
   // birthday: '',
   // cardId: '',
    id : null,
    mark: '',
  //  phone: '',
   // realName: '',
    status: false
  }
  export default {
    name: "UserEdit",
    props:{
      uid: {
        type: Number,
        default: null
      }
    },
    data() {
      return {
        ruleForm: Object.assign({}, defaultObj),
        groupData: [],
        rules: {}
      }
    },
    mounted() {
      if(this.uid) this.userInfo()
    },
    methods: {
      // 详情
      userInfo () {
        //userInfoApi({ id: this.uid}).then(async res => {
        //后期接口调用
        let res = {"uid":7933,"account":"15812980822","realName":"","birthday":"","cardId":"","mark":"","partnerId":null,"groupId":"","tagId":"","nickname":"b1f372d99453","avatar":"https://api.java.crmeb.net/crmebimage/store/2020/08/15/adae23e354114cd5bd8f3cae740741c23opxeh8kw2.jpg","phone":"15812980822","sex":0,"country":"CN","addIp":"","lastIp":"","nowMoney":"0.00","brokeragePrice":"0.00","integral":0,"experience":0,"signNum":0,"status":true,"level":0,"spreadUid":0,"spreadTime":null,"userType":"h5","isPromoter":false,"payCount":0,"spreadCount":0,"addres":"","adminid":0,"loginType":"","updateTime":"2022-10-25 00:15:13","createTime":"2022-10-25 00:15:13","lastLoginTime":"2022-10-25 00:15:13","cleanTime":null,"path":"/0/","subscribe":false,"promoterTime":null};

          this.ruleForm = {
            //本身注释
           // birthday: res.birthday,
           // cardId: res.cardId,
            id : res.uid,
            mark: res.mark,
           // phone: res.phone,
           // realName: res.realName,
            status: res.status,
          }
        //})
      },
      submitForm:Debounce(function(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            //userUpdateApi({id: this.ruleForm.id},this.ruleForm).then(async res => {
              this.$message.success('编辑成功')
              this.$parent.$parent.visible = false
              this.$parent.$parent.getList()
            //})
          } else {
            return false;
          }
        });
      }),
      resetForm(formName) {
        this.$refs[formName].resetFields();
        this.$emit('resetForm');
      }
    }
  }
</script>

<style scoped>
 .selWidth{
   width: 90%;
 }
</style>
